import * as types from '../actions/ActionTypes'
const initialState = {
  videoTotal:0,
  videoList:[],
  isLoadingTail:false,
  isRefreshing:false,
  popup:null
}
export default videoReducer = (state = initialState,action)=>{
  switch(types){
    case types.SHOW_ALERT:
      return {
        ...state,
        popup:{
          title:action.payload.title,
          contnet:action.payload.contnet
        }
      }
    case types.HIDE_ALERT:
      return{
        ...state,
        popup:null
      }
    case types.FETCH_CREATIONS_START:
      return{
        ...state,
        isLoadingTail:action.payload,
        isRefreshing:action.payload.isRefreshing
      }
    case types.FETCH_CREATIONS_FULFILLED:
      return{
        ...state,
        videoList:action.payload.videoList,
        videoTotal:action.payload.videoTotal,
        isLoadingTail:action.payload.isLoadingTail,
        isRefreshing:action.payload.isRefreshing
      }
      case types.FETCH_CREATIONS_REGECTED:
        return{
          ...state,
          err:action.payload.err,
          isLoadingTail:action.payload,
          isRefreshing:action.payload.isRefreshing
        }
    default:
      return state
  }
}